package com.msti.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.msti.entity.Course;
import com.msti.service.CourseMgtDAO;
import com.msti.service.CourseMgtDAOImpl;

/**
 * Servlet implementation class CreateCourse
 */
public class CreateCourse extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public CreateCourse() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Course course = new Course();
		course.setName(request.getParameter("name"));
		course.setFee(Integer.parseInt(request.getParameter("fee")));
		course.setCourseShortName(request.getParameter("shortName"));
		course.setDuration(request.getParameter("duration"));
		course.setType(request.getParameter("center"));
		CourseMgtDAO coMgtDAO = new CourseMgtDAOImpl();
		coMgtDAO.createNewCourse(course);
		response.sendRedirect("createCourse.jsp");
		
	}

}
